<template>
  <div>
    <el-card shadow="never" class="card">
      <div slot="header" class="clearfix">
        <span>简历受理情况</span>
        <span style="padding-left: 56%">当前共有 <el-button type="primary" size="mini" round>{{ page_data.page_total }}</el-button>份简历，其中受理通过的有<el-button
            type="success" size="mini" round>{{ page_data.tg }}</el-button>份</span>
      </div>
      <div id="charts_one" style="width:100%;min-height:300px">
        <el-button
            type="danger"
            size="small"
            icon="el-icon-finished"
            :disabled="selection_button_state"
            @click="show_selection"
        >{{ selection_button_title }}
        </el-button>
        <el-select v-model="value" placeholder="状态" style="width: 100px; margin-left: 50%">
          <el-option label="通过" value="通过"></el-option>
          <el-option label="未通过" value="未通过"></el-option>
          <el-option label="全部" value="全部"></el-option>
        </el-select>
        <el-input v-model="name" placeholder="毕业学校" style="width: 160px; margin-left: 6px"></el-input>

        <el-button type="primary" icon="el-icon-search" style="margin-left: 10px;" @click="seach">搜索</el-button>

        <el-table
            size="small"
            :data="user_data"
            max-height="350"
            @selection-change="selection"
            style="width: 100%"
            align="center"
        >
          <el-table-column type="selection" width="55" align="center"></el-table-column>
          <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
          <el-table-column label="详情" width="70" align="center">
            <template slot-scope="scope">
            <el-button size="mini" type="primary" icon="el-icon-edit" @click="stuinfo(scope.row.uid,scope.row.resume.tid,scope.row.resume.wid)"></el-button>
            </template>
          </el-table-column>
          <el-table-column property="name" label="姓名" align="center"></el-table-column>
          <el-table-column property="resume.gw" label="投递岗位" align="center"></el-table-column>
          <el-table-column property="school" label="毕业学校" align="center"></el-table-column>
          <el-table-column property="major" label="所学专业" align="center"></el-table-column>
          <el-table-column property="time" label="毕业时间" align="center"></el-table-column>
          <el-table-column property="telephone" label="联系电话" align="center"></el-table-column>
          <el-table-column property="sex" label="性别" align="center"></el-table-column>
          <el-table-column property="resume.status" label="状态" align="center"></el-table-column>
          <el-table-column label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button size="mini" type="success" @click="editor_user(scope.row.resume.tid,scope.row.resume.wid,scope.row.uid,scope.row.email,scope.row.name)">
                <i class="el-icon-edit-outline"/>
              </el-button>
              <el-popconfirm
                  confirmButtonText="确认删除"
                  cancelButtonText="取消"
                  confirmButtonType="danger"
                  cancelButtonType="success"
                  @onConfirm="delete_user(scope.row.uid,scope.row.resume.tid,scope.row.resume.wid)"
                  title="您确定删除该简历吗？"
              >
                <el-button size="mini" slot="reference" type="danger">
                  <i class="el-icon-delete"/>
                </el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>

        <el-pagination
            @size-change="page_size_change"
            @current-change="current_change"
            :current-page="page_data.page_num"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="page_data.row_num"
            layout="total, sizes, prev, pager, next, jumper"
            :total="page_data.page_total"
            style="margin-top:10px"
        ></el-pagination>
      </div>
    </el-card>
    <el-dialog :title="dialog_title" :visible.sync="dialog_viside_state">
      <el-form ref="form" :model="resume_form" label-width="80px">
        <label>是否通过</label>
        <el-form-item>
          <el-radio-group v-model="resume_form.status">
            <el-radio label="是">是</el-radio>
            <el-radio label="否">否</el-radio>
          </el-radio-group>
        </el-form-item>
       <label>回馈信息</label>
          <vTinymce v-model="resume_form.content" />

        <div align="center">
          <el-button
              type="success"
              size="small"
              @click="add()"
              v-show="password_input_state"
          >确认</el-button>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      resume_form:{
        status:"",
        content:"",
      },
      uid:"",
      wid:"",
      tid:"",
      email:"",
      names:"",
      dialog_viside_state: false,
      password_input_state: false,
      selection_button_title: "未选择数据",
      selection_button_state: true,
      selection_data: [],
      name:'',
      dialog_title: "",
      resume_status:'',
      resume_info:'',
      user_data: [],
      page_data: {
        row_num: 10,
        page_num: 1,
        page_total: 0,
        tg: 0,
      },
    };
  },
  methods: {
    add(){
      this.$axios({
        url: this.$axios.defaults.baseURL+"/enterprise/accept",
        method: "post",
        params: {
          uid:this.uid,
          wid:this.wid,
          tid:this.tid,
          status:this.resume_form.status,
          sm:this.resume_form.content,
          name:this.names,
          email:this.email,
        }
      }).then(res => {
        if(res.data.status){
          this.$message.success(res.data.msg);
        }else{
          this.$message.error(res.data.msg);
        }
        setTimeout(() => {
          this.dialog_viside_state = false;
          this.password_input_state = false;
        }, 1500);
      })
    },
    stuinfo(_uid,_tid,_wid){
      this.$router.push({path: '/resumeinfo', query: {uid:_uid,tid:_tid,wid:_wid}})
    },
    editor_user(_tid,_wid,_uid,_email,_name) {
      this.dialog_title = "受理简历";
      this.dialog_viside_state = true;
      this.password_input_state = true;
      this.uid = _uid;
      this.tid = _tid;
      this.wid = _wid;
      this.email = _email;
      this.names = _name;
    },
    selection(select_data) {
      if (
          select_data.length > 0 &&
          this.user_data.length != select_data.length
      ) {
        this.selection_button_title = "已选择" + select_data.length;
        this.selection_button_state = false;
        this.selection_data = select_data;
      } else if (this.user_data.length == select_data.length) {
        this.selection_button_title = "删除选中";
        this.selection_button_state = false;
        this.selection_data = select_data;
      } else {
        this.selection_button_title = "未选择数据";
        this.selection_button_state = true;
      }
    },
    delete_user(_uid,_tid,_wid) {
      this.$axios({
        url: this.$axios.defaults.baseURL+"/enterprise/delresumestu",
        method: "post",
        params: {
          tid: _tid,
          wid:_wid,
          uid:_uid,
        }
      }).then(res => {
        if(res.data){
          this.$message.success(res.data.msg);
          this.get_user_data(10, 1);
        }else {
          this.$message.error(res.data.msg);
        }
      })
    },
    show_selection() {
      this.$message.success("已打印选择数据成功，请打开检查查看");
      console.log(this.selection_data);
    },
    page_size_change(row_num) {
      this.page_data.row_num = row_num;
      this.$message.success('每页显示' + row_num + '条数据')
      this.get_user_data()
    },
    current_change(click_page) {
      this.page_data.page_num = click_page
      this.$message.success('正在展示第' + click_page + '页数据')
      this.get_user_data(this.row_num, click_page)
    },
    seach(){
      this.get_user_data(10,1)
    },
    get_user_data(_row, _currenpag) {
      //发送请求
      this.$axios({
        url: this.$axios.defaults.baseURL+"/enterprise/resumeacceptance",
        method: "get",
        params: {
          row: _row,
          currenpag: _currenpag,
          status : this.value,
          stu:this.name,
          uid:sessionStorage.getItem("enteruid")
        }
      }).then(res => {
        console.log(res.data.list);
        this.user_data = res.data.list;
        this.page_data.page_total = res.data.total;
        this.page_data.tg = res.data.tg;
      })
    },
  },

  mounted() {
    this.get_user_data(10, 1);
  },
};
</script>